package com.cskaoyan.javase.oop1._10exercise;
/**
 * 读程序题
 * 不管其他的,先找main方法
 * 程序的第一个输出是"Cat price"
 * 这是因为它的输出依赖于
 * 成员变量的显式赋值语句:
 * "Cat cat = new Cat(1000);"
 *
 * @since 11:38
 * @author wuguidong@cskaoyan.onaliyun.com
 */

public class Demo {
    public static void main(String[] args) {
        Student s = new Student(18, "长风");
        System.out.println(s.age);
        System.out.println(s.name);
        System.out.println(s.var);
        System.out.println(s.cat.price);
    }
}
class Student {
    int age = 10;
    String name = "张三";
    double var = 20;

    public Student(int age) {
        System.out.println("Student age");
        this.age = age;
    }

    public Student() {
    }

    public Student(int age, String name) {
        this(age);
        System.out.println("Student age,name");
        this.name = name;
    }

    // 引用数据类型成员变量的显式赋值,会创建对象
    // 类似于int a = 10;
    Cat cat = new Cat(1000);
    Cat c2;
    // Student s = new Student();
}

class Cat {
    double price;

    public Cat() {
    }

    public Cat(double price) {
        System.out.println("Cat price");
        this.price = price;
    }
}